package com.example.Lezedata.ui.activity.record;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.example.Lezedata.R;
import com.example.Lezedata.ui.activity.baseClass.GBBaseVc;
import com.example.Lezedata.util.GBUtil;

import java.util.ArrayList;

public class MemberRecordVC extends GBBaseVc {
    @Override
    protected int getLayoutId() {
        return R.layout.activity_member_record_v_c;
    }

    @Override
    public CharSequence title() {
        return "Member Mall Records";
    }

    ListView listView;
    ImageView head;
    TextView mobile;

    public String userId;

    BaseAdapter adapter;
    ArrayList models = new ArrayList();
    @Override
    protected void viewDidLoad() {
        super.viewDidLoad();
        userId = getIntent().getStringExtra("userId");
        findView();
        addLineToHeaderFooter();
        setAdapter();
        loadData();
    }

    void findView(){
        listView = findViewByTag("tableView");
        head = findViewByTag("head");
        mobile = findViewByTag("mobile");
    }

    void loadData(){
        models.add("");
        models.add("");
        models.add("");
        models.add("");
        models.add("");
        adapter.notifyDataSetChanged();
    }

    void addLineToHeaderFooter(){
        View headView = getLayoutInflater().inflate(R.layout.activity_member_record_head,null,false);
        listView.addHeaderView(headView);
        head = headView.findViewWithTag("head");
        mobile = headView.findViewWithTag("mobile");
        TextView line1 = new TextView(mContext);
        line1.setMaxHeight(GBUtil.pxTo2dp(mContext,15));
        line1.setBackground(new ColorDrawable(Color.TRANSPARENT));
        listView.addFooterView(line1);
    }

     void setAdapter() {
        adapter = new BaseAdapter() {
            @Override
            public int getCount() {
                return models.size();
            }

            @Override
            public Object getItem(int position) {
                return models.get(position);
            }

            @Override
            public long getItemId(int position) {
                return position;
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                if (convertView == null){
                    convertView = PrizesRecordCell.sharedCell(mContext);
                }
                return convertView;
            }
        };
        listView.setAdapter(adapter);
    }
}